<template>
  <div class="data-item" id="userFlow"></div>
</template>

<script>
  import { mapState } from 'vuex'
  import TrafficMap from '../../../../../utils/trafficMap'
  import { getTrafficHeatmap } from '../../../../../utils/http'

  export default {
    computed: {
      ...mapState(['cityInfo'])
    },
    mounted () {
      this.onReady()
    },
    methods: {
      async onReady () {
        const { cityInfo } = this
        const dom = document.getElementById('userFlow')
        const Map = new TrafficMap(dom, cityInfo.center, 13, map => {})
        Map.installHeatMap(await getTrafficHeatmap(cityInfo.cityCode))
      }
    }
  }
</script>
